from selenium.webdriver.common.by import By
from Base.Base import Base

class login_page(Base):

    #输入账号
    username_loc = (By.XPATH,'/html/body/div/div[2]/div[1]/form/div[2]/ul[1]/li[2]/input')
    # 输入密码
    password_loc = (By.XPATH, '/html/body/div/div[2]/div[1]/form/div[2]/ul[2]/li[2]/input')
    # 点击登录
    login_loc = (By.XPATH, '/html/body/div/div[2]/div[1]/form/div[3]/input')

    def input_username(self,username):
        '''
        输入用户名
        :param username: 用户名
        :return:
        '''
        try:
            self.send_keys(self.username_loc,username)
        except Exception as e:
            print(e)

    def input_password(self,password):
        '''
        输入密码
        :param password: 密码
        :return:
        '''
        try:
            self.send_keys(self.password_loc,password)
        except Exception as e:
            print(e)

    def click_login_btn(self):
        '''
        点击登录按钮
        :return:
        '''
        try:
            self.click(self.login_loc)
        except Exception as e:
            print(e)

    def act_login(self,username,password):
        self.open_url('http://82.156.27.230:7009//roncoo-pay-web-boss/login')
        self.input_username(username)
        self.input_password(password)
        self.click_login_btn()
        return


